<template>
  <el-dialog title="查看上架数据" :visible.sync="open" width="70%" append-to-body @close="cancel">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="80px">
      <el-form-item label="产品ID" prop="aeProductId">
        <el-input v-model="queryParams.aeProductId" placeholder="请输入产品id" clearable/>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择状态">
          <el-option v-for="(item,index) in dict.type.pulish_product_task_status" :key="index" :label="item.label"
                     :value="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="备注" prop="remark">
        <el-input v-model="queryParams.remark" placeholder="请输入备注进行搜索" clearable/>
      </el-form-item>
      <el-form-item label="日期范围" prop="startTime">
        <el-date-picker v-model="timeRange" range-separator="至" value-format="yyyy-MM-dd"
                        start-placeholder="开始日期" type="daterange"
                        end-placeholder="结束日期" placeholder="选择日期范围">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <!--  店铺列表  -->
    <el-table v-loading="loading" :data="autoOperationStoreList" border stripe>
      <el-table-column label="采集商品ID" prop="collectProductId" align="center"/>
      <el-table-column label="执行时间" prop="executionTime" align="center"/>
      <el-table-column label="速卖通id" prop="aeProductId" align="center" width="200">
        <template slot-scope="scope">
          {{ scope.row.aeProductId ? scope.row.aeProductId : "暂无" }}
        </template>
      </el-table-column>
      <el-table-column label="备注" prop="remark" align="center">
        <template slot-scope="scope">
          {{ scope.row.remark ? scope.row.remark : '暂无' }}
        </template>
      </el-table-column>
      <el-table-column label="状态" prop="status" align="center">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.pulish_product_task_status" :value="scope.row.status"></dict-tag>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="confirm()">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import {getPulishProductProjectTaskList} from "@/api/autoOperation/ground"

export default {
  name: "index",
  dicts: ['pulish_product_task_status'],
  props: {
    configId: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      loading: false,
      showSearch: true,
      open: true,
      autoConfigValue: "0",
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        projectId: this.configId,
        endTime: undefined,
        startTime: undefined,
        aeProductId: undefined,
        status: undefined
      },
      autoOperationStoreList: [],//自运营店铺列表
      total: 0,//数据总条数
      timeRange: "",// 时间范围
    }
  },
  created() {
    this.getList()
  },
  methods: {
    // 获取店铺列表
    getList() {
      this.loading = true
      getPulishProductProjectTaskList(this.queryParams).then(res => {
        this.loading = false
        let data = res.data
        this.autoOperationStoreList = data.list
        this.total = data.total
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      if (this.timeRange) {
        this.queryParams.startTime = this.timeRange[0]
        this.queryParams.endTime = this.timeRange[1]
      }
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.timeRange = ""
      this.queryParams.startTime = ""
      this.queryParams.endTime = ""
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.userId)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    cancel() {
      this.open = false
      this.$emit('close')
    },
  }
}
</script>

<style scoped>

</style>
